You are here: Scripting Reference > Data Types > String (String, Widestring)

String (String, Widestring)

Declaration

var myvariable : string

var myvaraible : widestring;

Example

procedure ScriptEvent (var Value : variant)

var myvariable : string

begin

myvariable := 'Hello World';

loginfo('the value of myvariable is '+myvariable);

end

 

Description

String is used to represent an array of characters. A string can contain any character. A WideString is also capable of storing unicode characters.

When entered into a script a string is enclosed within single quotes.

Value := 'This is a string of characters';

Should you need to represent a single quote within the string itself enter it as two single quotes. For example to represent the string "Hello, my name's Cameron"

Value := 'Hello, my name''s Cameron';

In the above example there are two single quotes between the e and s in name's

Most SQL Databases also use a single quote to represent strings in a SQL statement. Flow will correctly manage the conversion of single quotes when working with DB Definitions. However it is common to write custom SQL statements within the map script and you should take care to use the correct quoting so the resulting SQL is correct.

Strings can be concatenated together with the + operator. Be careful when adding number types to strings as the script engine may confuse whether you want to concatenate or add. Refer to the following example

MyFloatVariable := 123.45;

Value := 'The amount is $' + MyFloatVariable;

In the above example the intention is to have a string with the contents "The amount is $123.45". However this may confuse the script engine resulting in an error particularly if MyFloatVariable has been defined as a See "Variant (Variant)". You should explicitly convert the value as in the next example

MyFloatVariable := 123.45;

Value := 'The amount is $' + FloatToStr(MyFloatVariable);

Memo fields in DB Definitions are also strings however they can require special functions to handle working with their values.